package thread;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/4/27
 * Time:11:20
 * 守护线程-用户线程
 **/
public class ThreadDemo9 {
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            //在守护线程的内部创建的线程
            Thread t2 = new Thread(() -> {//用户线程

            });
            System.out.println("t2是" + (t2.isDaemon() ? "守护线程" : "用户线程"));
        });
        //设置为守护线程
        //t1.setDaemon(true);
        //若t1为守护线程，则t2也是守护线程

        t1.start();
        System.out.println("t1是否为守护线程" + t1.isDaemon());
    }
}
